package _interview75;

import _object.ListNode;

/**
 * 2095. 删除链表的中间节点
 */
public class No2095 {
    public ListNode deleteMiddle(ListNode head) {
        if (head.next == null) return null;
        ListNode sent = new ListNode(-1, head);
        ListNode slow = head, fast = head, pre = head;
        while (fast != null && fast.next != null) {
            pre = slow;
            slow = slow.next;
            fast = fast.next.next;
        }
        pre.next = slow.next;
        return sent.next;
    }
}
